package com.pengcheng.taskapplication.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.pengcheng.taskapplication.R;
import com.pengcheng.taskapplication.model.LicenseModel;
import com.pengcheng.taskapplication.mvp.view.widget.CircleImageView;

import java.util.List;

public class XSZAdapter extends BaseAdapter {

	Context context;
	LayoutInflater inflater;
	List<LicenseModel> applyModels;
	int last_item;
	private int selectedPosition = -1;
	public XSZAdapter(Context context, List<LicenseModel> applyModels){
		this.context = context;
		this.applyModels = applyModels;
		inflater= LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return applyModels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return applyModels.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder  holder = null;
		if(convertView==null){
			convertView = inflater.inflate(R.layout.activity_xsz_list_item_layout, null);
			holder = new ViewHolder();
//			holder.circleImage=(CircleImageView)convertView.findViewById(R.id.img_left);
//			holder.tv_task_name =(TextView)convertView.findViewById(R.id.tv_task_name);
//			holder.tv_task_price=(TextView)convertView.findViewById(R.id.tv_task_price);
//			holder.tv_last=(TextView)convertView.findViewById(R.id.tv_last);
//			holder.task_competed=(TextView)convertView.findViewById(R.id.task_competed);
//			holder.type_name=(TextView)convertView.findViewById(R.id.type_name);
			convertView.setTag(holder);
		}
		else{
			holder=(ViewHolder)convertView.getTag();
		}

//		TaskVo model= applyModels.get(position);
//		holder.tv_task_name.setText(model.getTaskname());
//		holder.tv_task_price.setText("+"+String.format("%.2f", model.getTaskperprice()));
//		holder.type_name.setText(model.getTypename());
//		holder.tv_last.setText("剩余"+model.getTasknum());
//		holder.task_competed.setText("已完成"+(model.getTaskcount()-model.getTasknum()));
//		ImageLoader.displayImageDefaultCircle(context,model.getUserimage(),(ImageView) holder.circleImage);
		return convertView;
	}

	public static class ViewHolder{
		public TextView tv_task_name;
		public TextView tv_task_price;
		public TextView task_competed;
		public TextView tv_last;
		public TextView type_name;
		public CircleImageView circleImage;

	}

	public void setSelectedPosition(int position) {
		selectedPosition = position;
	}

}
